package com.hphs.controller;

import com.hphs.model.Category;
import com.hphs.model.CategoryQuery;
import com.hphs.model.Product;
import com.hphs.model.ProductQuery;
import com.hphs.service.CategoryService;
import com.hphs.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/product")
public class ProductController {
    @Autowired
    private ProductService service;

    @GetMapping
    public List<Product> select(ProductQuery query){

        return service.select(query);
    }

    @PostMapping
    public int insert(@RequestBody Product product){
        return service.insert(product);
    }
    @PutMapping
    public int update(@RequestBody Product product){
        return service.update(product);
    }

    //删除 软删除
    @DeleteMapping
    public  int delete(Integer id){
        return service.delete(id);
    }
}
